package main
//冒泡
import "fmt"

func main()  {
	values := []int{4,83,45,98,121,94,28,12,32,80,81}
	//BubbleAsort(values)
	//BubbleZsort(values)
	BubbleSort(values)
}

func BubbleSort(values []int) {
	tmp := 0
	for i := 0; i < len(values); i++ {
		for j := 0; j < len(values)-1; j++ {
			if values[j] > values[j+1]{
				tmp = values[j]
				values[j] = values[j+1]
				values[j+1] = tmp
			}
			fmt.Println(values)
		}
	}
	//fmt.Println(values)
}

func BubbleAsort(values []int)  {
	for i:=0;i<len(values);i++{
		for j:=i+1;j<len(values);j++{
			if values[i] > values[j]{
				values[i],values[j] = values[j],values[i]
			}
		}
	}
	fmt.Println(values)
}

func BubbleZsort(values []int) {
	for i := 0; i < len(values)-1; i++ {
		for j := i+1; j < len(values); j++ {
			if  values[i]<values[j]{
				values[i],values[j] = values[j],values[i]
			}
		}
	}
	fmt.Println(values)
}